﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ERP_RORZE_DLL.Product.DAO;
using ERP_RORZE_PERMISSION.Base;
using ERP_RORZE_PRODUCT.Product.database;

namespace ERP_RORZE_PRODUCT.Product.BasicList
{
    public partial class frm_CustomerEdit : DevExpress.XtraEditors.XtraForm
    {
        public event EventHandler Reload;
        ClsBasicListDAO clsBasiclistDAO = new ClsBasicListDAO();
        ClsCustomerTable b = new ClsCustomerTable();
        private LogUtils log;

        public string ID;
        public string Name;
        public string Info;

        public frm_CustomerEdit()
        {
            InitializeComponent();
            log = new LogUtils();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnEdit_Click(object sender, EventArgs e)
        {
        //    if (txtCustomerName.Text == "")
        //    {
        //        MessageBox.Show("Chưa nhập Customer Name");
        //    }
        //    else if (txtCusInfo.Text == "")
        //    {
        //        MessageBox.Show("Chưa nhập Customer Info");
        //    }
        //    else
        //    {
                b.CustomerID = txtCustomerID.Text;
                b.CustomerName = txtCustomerName.Text;
                b.CusInfo = txtCusInfo.Text;
                clsBasiclistDAO.UpdateCustomer(b);

                //write Log
                log.Table = LogConstant.Table.Product.Customer;
                log.Task = LogConstant.Task.Update;
                log.Description = b.CustomerID;
                log.WriteLog();

                MessageBox.Show("Đã nhập xong");
                Reload(sender, e);
            //}
        }

        private void frm_CustomerEdit_Load(object sender, EventArgs e)
        {
            txtCustomerID.Text = ID;
            txtCustomerName.Text = Name;
            txtCusInfo.Text = Info;
        }
    }
}